package com.pig4cloud.pig.demo.controller;

import com.pig4cloud.pig.demo.dto.Result;
import com.pig4cloud.pig.demo.dto.SmartAppGoodsCategoryDto;
import com.pig4cloud.pig.demo.feign.SmartAppGoodsCategoryFeign;
import com.pig4cloud.pig.demo.service.SmartAppGoodsCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("SmartAppGoodsCategory 商品分类接口")
@RestController
@RequestMapping("/demo-biz/goodsCategory/")
public class SmartAppGoodsCategoryController implements SmartAppGoodsCategoryFeign {
	@Autowired
	SmartAppGoodsCategoryService categoryService;

	@ApiOperation("分类列表")
	@GetMapping("/getList")
	@Override
	public Result<List<SmartAppGoodsCategoryDto>> getList() {
		return categoryService.getList();
	}

	@ApiOperation("通过id获取分类")
	@GetMapping("/getById/{id}")
	@Override
	public Result<SmartAppGoodsCategoryDto> getById(@PathVariable("id") Long id) {
		return categoryService.getById(id);
	}

	@ApiOperation("新增分类")
	@PostMapping("/add")
	@Override
	public Result add(@RequestBody SmartAppGoodsCategoryDto categoryDto) {
		return categoryService.add(categoryDto);
	}

	@ApiOperation("更新分类")
	@PutMapping("/update")
	@Override
	public Result update(@RequestBody SmartAppGoodsCategoryDto categoryDto) {
		return categoryService.update(categoryDto);
	}

	@ApiOperation("删除分类")
	@DeleteMapping("/delete")
	@Override
	public Result delete(@PathVariable("id") Long id) {
		return categoryService.delete(id);
	}
}
